package exercise;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

public class Exercise1 {
	public static void main(String[] args) {
		ArrayList<String> list = new ArrayList<>();
//		HashMap<String,Integer> map = new HashMap<>();
		Collections.addAll(list, "zhangsn,23","lisi,24","wangwu,25");
		/*for(int i=0;i<list.size();i++){
			String name = list.get(i).split(",")[0];
			int age = Integer.parseInt(list.get(i).split(",")[1]);
			if(age>24){
				map.put(name, age);
			}
		}
		System.out.println(map);*/
		Map<String, String> collect = list.stream().filter(new Exercise1()::needAge)
		.collect(Collectors.toMap(s->s.split(",")[0], s->s.split(",")[1]));
		System.out.println(collect);

		
	}
	public boolean needAge(String s){
		return Integer.parseInt(s.split(",")[1])>24;
	}
}
